﻿using HighDiveEngine.Model;
using NUnit.Framework;

namespace UnitTestHighDive
{
    [TestFixture]
    public class UnitTestContest
    {
        [SetUp]
        public void SetUp()
        {
            UnitTestMockObjects.ResetObjects();
        }

        [Test]
        public void TestUnitUpdateDiveQueue()
        {
            Assert.AreEqual(3, UnitTestMockObjects._contest1.DiveQueue.Count);
            Assert.AreEqual(3, UnitTestMockObjects._contest1.DiveHistory.Count);
            UnitTestMockObjects._contest1.UpdateDiveQueue();
            Assert.AreEqual(4, UnitTestMockObjects._contest1.DiveHistory.Count);
            Assert.AreEqual(2, UnitTestMockObjects._contest1.DiveQueue.Count);
        }

        [Test]
        public void TestUnitTotalScore()
        {
            Assert.AreNotEqual(null, UnitTestMockObjects._dive11.TotalScore);
        }

        //[Test]
        //public void TestUnitUpdateDiveScoreWillUpdateQueue()
        //{
        //    Dive dive = new Dive() { Diver = UnitTestMockObjects._diver1, DiveCode = "404B" , DiveHeight = 5};
        //    dive.CalculateDifficulty();
        //    UnitTestMockObjects._contest1.DiveQueue.Insert(0,dive);
        //    //UpdateQueue ska kallas om hoppet ligger först i kön.
        //    Assert.AreEqual(4, UnitTestMockObjects._contest1.DiveQueue.Count);
        //    Assert.AreEqual(3, UnitTestMockObjects._contest1.DiveHistory.Count);
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge1});
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge2});
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge3});
        //    Assert.AreEqual(3, UnitTestMockObjects._contest1.DiveQueue.Count);
        //    Assert.AreEqual(4, UnitTestMockObjects._contest1.DiveHistory.Count);

        //    //UpdateQueue ska ej kallas om hoppet inte ligger först i kön.            
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge1 });
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge2 });
        //    UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore() { Score = 3, Dive = dive, Judge = UnitTestMockObjects._judge3 });
        //    Assert.AreEqual(3, UnitTestMockObjects._contest1.DiveQueue.Count);
        //    Assert.AreEqual(4, UnitTestMockObjects._contest1.DiveHistory.Count);
        //}

        [Test]
        public void TestUpdateDiveScoreInHistory()
        {
            int sc = 300;
            Dive dive = UnitTestMockObjects._contest1.DiveHistory[0];
            DiveScore score = UnitTestMockObjects._contest1.DiveHistory[0].DiveScoreList.Find(
                x => x.Judge.IdString == UnitTestMockObjects._judge1.IdString);
            UnitTestMockObjects._contest1.UpdateDiveScore(new DiveScore(){Judge = UnitTestMockObjects._judge1, Score = sc}, dive);
            Assert.AreEqual(sc, score.Score);
        }

    }
}
